<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>登录</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<link rel="stylesheet" href="./AmazeUI-2.4.2/assets/css/amazeui.css" />
		<link href="./css/dlstyle.css" rel="stylesheet" type="text/css">

		<!--引入Vue + axios-->
		<script src="js/plugins/vue/dist/vue.js"></script>
		<script src="js/plugins/axios/dist/axios.js"></script>
		<!--引入公共配置-->
		<script src="js/common.js"></script>

	</head>

	<body>

	<div id="myDiv"></div>
	</body>
	<script type="text/javascript">
        new Vue({
            el:"#myDiv",
            mounted(){
                //解析参数上
                let url = location.href;
                let paramObj = parseUrlParams2Obj(url);
                //console.log(paramObj);
                //封装请求参数
                let param = {"code":paramObj.code};
                console.log(paramObj.code);
                //发送微信登录验证
                this.$http.post("/login/wechat",param)
                    .then(result=>{
                        //console.log(result);
                        result = result.data;//AjaxResult
                        if(result.success){
                            //解构表达式解构对象
                            let {token,loginInfo} = result.resultObj;
                            //储存数据 token + loginInfo
                            localStorage.setItem("token",token);
                            localStorage.setItem("loginInfo",JSON.stringify(loginInfo));
                            //跳转到主页
                            location.href="index.html"
                        }else{
                            let binderUrl="http://bugtracker.itsource.cn/binder.html"+result.resultObj;
                            location.href=binderUrl;
                        }
                    })
                    .catch(result=>{
                        alert("系统异常!");
                    })

            }
        })

	</script>


</html>